#include "main.h"
#include "gpio.h"
#include "FreeRTOS.h"
#include "task.h"
#include "cmsis_os.h"
#include "serial.h"
#include "key.h"

extern osThreadId key_scanHandle;
extern TimerHandle_t mykeytimerHandle;

uint8_t enter_num=0;
uint8_t add_num=1;
uint8_t sub_num=2;
extern osMessageQId key_numHandle;

void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
	if(GPIO_Pin == enter_Pin |GPIO_Pin == add_Pin|GPIO_Pin == sub_Pin)
	{
		BaseType_t status=pdFALSE;
		osTimerStart(mykeytimerHandle,30);
		if(status == pdTRUE)
		{
			portYIELD_FROM_ISR(status);
		}
	}
	
}

void Key_Scan(uint16_t GPIO_Pin)
{	

//	BaseType_t pxHigherPriorityTaskWoken;
//	
//	if( GPIO_Pin == enter_Pin)
//	{

//		xQueueSendFromISR(key_numHandle,&enter_num,&pxHigherPriorityTaskWoken);
//		vTaskResume(key_scanHandle);
//		portYIELD_FROM_ISR(&pxHigherPriorityTaskWoken);
//	}
//	if( GPIO_Pin == add_Pin)
//	{
//		xQueueSendFromISR(key_numHandle,&add_num,&pxHigherPriorityTaskWoken);
//		portYIELD_FROM_ISR(&pxHigherPriorityTaskWoken);
//	}
//	if( GPIO_Pin == sub_Pin)
//	{
//		xQueueSendFromISR(key_numHandle,&sub_num,&pxHigherPriorityTaskWoken);
//		portYIELD_FROM_ISR(&pxHigherPriorityTaskWoken);
//	}
}
